﻿using System;
using System.Runtime.InteropServices;

namespace QuotationService.RealtimeQuotation
{
    /// <summary>
    /// 证券基本资料
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
    internal struct StockBasicInfo
    {
        /// <summary>
        /// 商品代码
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.CodeLength)]
        public string Code;

        /// <summary>
        /// 商品名称
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.NameLength)]
        [ServiceManager.Utils.Encoding("UTF-8")]
        public string Name;

        /// <summary>
        /// 证券简称前缀
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5)]
        public string ShortPrefix;

        /// <summary>
        /// 英文简称
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
        public string EnglishName;

        /// <summary>
        /// 基础证券
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)]
        public string BaseStock;

        /// <summary>
        /// ISIN 编码
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 13)]
        public string ISINCode;

        /// <summary>
        /// 商品类别
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
        public string Type;

        /// <summary>
        /// 货币种类
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)]
        public string CurrencyType;

        /// <summary>
        /// 行情来源
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.QuotLevelLength)]
        public string QuotLevel;

        /// <summary>
        /// 行业种类
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)]
        public string IndustryType;

        /// <summary>
        /// 交易类别
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.TradeTypeLength)]
        public string TradeType;

        /// <summary>
        /// 涨停价
        /// </summary>
        public double MaxOrderPrice;

        /// <summary>
        /// 跌停价
        /// </summary>
        public double MinOrderPrice;

        /// <summary>
        /// 开盘价
        /// </summary>
        public double OpenPrice;

        /// <summary>
        /// 昨收盘价
        /// </summary>
        public double PreClosePrice;

        /// <summary>
        /// 上市日期
        /// </summary>
        public Int32 BeginDate;

        /// <summary>
        /// 到期/交割日
        /// </summary>
        public Int32 EndDate;

        /// <summary>
        /// 退市日期
        /// </summary>
        public Int32 AccountDate;


        /// <summary>
        /// 价格档位
        /// </summary>
        public double OrderPriceUnit;

        /// <summary>
        /// 小数位数
        /// </summary>
        public Int32 Decimal;

        /// <summary>
        /// 交易单位
        /// </summary>
        public Int32 TradeUnit;

        /// <summary>
        /// 买入下限
        /// </summary>
        public Int32 LowBuyQtyLimit;

        /// <summary>
        /// 卖出下限
        /// </summary>
        public Int32 LowSellQtyLimit;

        /// <summary>
        /// 买入上限
        /// </summary>
        public Int32 HighBuyQtyLimit;

        /// <summary>
        /// 卖出上限
        /// </summary>
        public Int32 HighSellQtyLimit;

        /// <summary>
        /// 每股面值
        /// </summary>
        public double ParValue;

        /// <summary>
        /// 总发行量
        /// </summary>
        public Int64 TotalIssueQty;

        /// <summary>
        /// 流通股数
        /// </summary>
        public Int64 TotalCirculatingShare;

        /// <summary>
        /// 每百元应计利息
        /// </summary>
        public double AccuredInterest;

        /// <summary>
        /// 昨日成交量
        /// </summary>
        public Int64 PreExchTotalKnockQty;

        /// <summary>
        /// 昨日成交金额
        /// </summary>
        public double PreExchTotalKnockAmt;

          /// <summary>
        /// 每手数量
        /// </summary>
        public Int32 ConvertQty;

        /// <summary>
        /// 交易状态
        /// </summary>
        public char TradeStatus;

        /// <summary>
        /// 交收天数
        /// </summary>
        public Int16 StkDeliveryDays;

        /// <summary>
        /// 停盘标志
        /// </summary>
        public char SuspendedFlag;

        /// <summary>
        /// 上年每股利润
        /// </summary>
        public double LastAnnualProfit;

        /// <summary>
        /// 本年每股利润
        /// </summary>
        public double AnnualProfit;

        /// <summary>
        /// 债券起息日
        /// </summary>
        public Int32 BondBonusDate;

        /// <summary>
        /// 债券折合比例
        /// </summary>
        public double BondConvertRate;

        /// <summary>
        /// 担保物折算率
        /// </summary>
        public double GuarantyConvertRate;

        /// <summary>
        /// 融资标的标志
        /// </summary>
        public char FinancingLoanFlag;

        /// <summary>
        /// 融券标的标志
        /// </summary>
        public char SecuritiesLoanFlag;

        /// <summary>
        /// 成份股标志
        /// </summary>
        public char ComponentStockFlag;

        /// <summary>
        /// 做市商标志
        /// </summary>
        public char MarketMakerFlag;

        /// <summary>
        /// 证券级别
        /// </summary>
        public char LevelFlag;

        /// <summary>
        /// 产品交易阶段
        /// </summary>
        public char TradeStageFlag;

        /// <summary>
        /// 融资交易状态
        /// </summary>
        public char FinancingLoanTradingFlag;

        /// <summary>
        /// 融券交易状态
        /// </summary>
        public char SecuritiesLoanTradingFlag;

        /// <summary>
        /// 融券卖出价格限制
        /// </summary>
        public char SecuritiesLoanSellPriceLimitFlag;

        /// <summary>
        /// 网络投票标志
        /// </summary>
        public char VoteFlag;

        /// <summary>
        /// 其他业务状态
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
        public string OtherBizStatus;


        /// <summary>
        /// 回购天数
        /// </summary>
        public int RepurchaseDay;


        /// <summary>
        /// 静态资料版本，格式为：YYYYMMDDxxxxxx，即：年月日+递增数字
        /// </summary>
        public Int64 StaticVer;

        /// <summary>
        /// 动态资料版本，格式为：YYYYMMDDxxxxxx，即：年月日+递增数字
        /// </summary>
        public Int64 DynamicVer;

        /// <summary>
        ///记录更新的时间
        /// </summary>
        public DateTime UpdateTime;

        /// <summary>
        /// 行情记录中包含的行情时间
        /// </summary>
        public DateTime QuotationTime;
    }
}
